home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 27.zip / BS1 part 27 / ImageMaster_d3.adf / piarc.lzh.parta / launch.rexx < prev    next >
OS/2 REXX Batch file  |  1993-03-23  |  3KB  |  100 lines

  1. /*
  2.  * launch.rexx  a P.I. module to launch another script using the 
  3.  *               image processor's list requester
  4.  *               
  5.  *
  6.  *  Written by: Barry Chalmers
  7.  * Last Update: March 3rd, 1992
  8.  *    Revision: 1.01
  9.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  10.  */
  11.  
  12. parse arg firstarg ',' secondarg
  13. call pragma('stack',20000);
  14.  
  15. /*
  16.  * open rexxsupport.library -- needed for some functions
  17.  */
  18. if ~show('L',"rexxsupport.library") then do
  19.   if addlib('rexxsupport.library',0,-30,0) then do
  20.       /* everything's ok */
  21.     end;
  22.   else do
  23.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  24.     say 'Cannot operate RESOLVER.rexx without this library - sorry!';
  25.     exit 10;
  26.     end;
  27.   end;
  28.  
  29. /*
  30.  * This will automatically direct the script to the proper
  31.  * software, if it is running. No matter where the script is
  32.  * launched from. :^) I sure do like ARexx. :^))
  33.  */
  34. prtnme = 'IP_Port'; /* assume Image Professional */
  35. if show('P','IP_Port') = 0 then do
  36.   if show('P','IM_Port') = 0 then do
  37.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  38.     say "This script requires IP, IM or IM F/c to run!";
  39.     exit(20);
  40.     end;
  41.   else do
  42.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  43.     end;                 /* We make em, user's break em.          */
  44.   end;
  45.  
  46.   /*
  47.    * This code attempts to read a file called "picmdpath" from REXX:
  48.    * If it can't find it, the script will assume that the commands
  49.    * associated with this PI Module are in "c:". If the file exists,
  50.    * the script will look in the path that is specified in the file.
  51.    * If you create this file, you MUST put a complete, correct path
  52.    * in it; if the commands are in a sub-directory, you have to put
  53.    * the trailing slash on the path (like, device:dir/).
  54.    * 
  55.    */
  56.   cmdpath = 'c:';
  57.   if open(fhandle,'rexx:picmdpath','read') then  /* open the file */
  58.     do
  59.       cmdpath = readln(fhandle);
  60.       call close(fhandle);  /* close the file    */
  61.     end
  62.  
  63. address(prtnme);
  64.  
  65. prevgfunc = '';
  66. if show('C',prefunk) = 1 then
  67.   do
  68.     prevgfunc = getclip(prefunk);
  69.   end;
  70.  
  71. if firstarg = '' then 
  72.   do
  73.     'message "The Script Launcher requires a LIST name"';
  74.   end
  75.  
  76. options results
  77. 'listreq "Launch a P.I. Module","'||cmdpath||firstarg||'",'||secondarg
  78. tname = result
  79. options
  80.  
  81. if tname = '' then 
  82.   do
  83.     exit 0;
  84.   end
  85.  
  86. name = "rxpi:"||tname   /* Let the OS handle the .rexx extension */
  87.  
  88. parse var name rname ':' fname '.' ename
  89.  
  90. if ename = 'rexx' then
  91.   do
  92.     call setclip(prefunk,fname);
  93.   end
  94. /*
  95.  * This should simply launch the requested script:
  96.  */
  97. address command 'rx '||name
  98.  
  99. exit 0;
  100.